<template>
  <Layout class="layout" :class="layoutClass">
    <!-- 移动端遮罩层 - 当侧边栏打开时显示 -->
    <div v-if="isMobile && isSidebarOpen" class="layout__overlay" @click="closeSidebar" />
    <slot></slot>
  </Layout>
</template>

<script setup>
import { Layout } from 'ant-design-vue'
import { useDeviceDetection } from '@/composables/layout/useDeviceDetection.js'
import { useLayout } from '@/composables/index.js'
import { useAppStore } from '@/store/index.js'

const { isMobile } = useDeviceDetection()
const { layoutClass, isSidebarOpen } = useLayout()
const { closeSidebar } = useAppStore()
</script>

<style lang="scss" scoped>
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  &__overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
  }
}
</style>
